<?php defined('BASE_PATH') or die('No direct script access.');
/**
 * Gialac php framework
 * Session Library
 * @package    libraries
 * @category   Storage
 * @author     Gialachoanglong,Windy261
 * @copyright  (c) 2011
 */
final class Session {
//    protected $registry;
//    public function __construct($registry){
//        @session_start();
//        $this->registry = $registry;
//    }
public function __construct(){
        @session_start();
    }
    //auto set
    public function __set($key,$value) {
        $_SESSION[$key]=$value;
    }
    // auto get
    public function __get($name) {
        return (isset($_SESSION[$name]) ? $_SESSION[$name] : NULL);
    }
    // set multi session with array
    public function set($data) {
        if(is_array($data)) {
            foreach($data as $key=>$value) {
                $_SESSION[$key]=$value;
            }
        }
    }
    //show all
    public function all() {
       return $_SESSION;
    }
    // remove a single session or multi session with array
    public function remove($data) {
        if(is_array($data)) {
            foreach($data as $item) {
                unset($_SESSION[$item]);
            }
        }else {
            unset($_SESSION[$data]);
        }
    }

    //Remove All Session
    public function destroy() {
        session_destroy();
    }

} // End Session Library